﻿<cfscript>
/** 
* ORM Teacher
* 
* @hint "Hibernate persistenter t_teacher. 教师信息表" 
* 
*/ 

component 
	displayname="public.service.orm.senate.Teacher" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="Teacher" 
	table="t_teacher"
	{

	property type="string" name="TeacherID" column="tch_id" fieldtype="id" generator="assigned" hint="教师职工号";

	property type="string" name="TeacherName" column="tch_name" hint="教师姓名";
	property type="string" name="TeacherPinyin" column="tch_pyidx" hint="教师姓名拼音";
	property type="string" name="TeacherSex" column="tch_sex" hint="性别";
	property type="string" name="TeacherIDCard" column="tch_idcard" hint="教师身份证号";
	property type="string" name="TeacherEmail" column="tch_email" hint="教师电子邮件";
	property type="string" name="TeacherTelephone" column="tch_tel" hint="教师联系电话";
	property type="string" name="ProfileCreate" column="tch_create" hint="档案建立时间";
	property type="string" name="ProfileLastUpdate" column="tch_lastupdate" hint="档案最后更新时间";
	
	property name="BookBills" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="BookBill" hint="教材出入库票据";

	property name="Books" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="TeacherBook" hint="教师参考用书";
	property name="ManagedDepartments" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="InstituteAdmin" hint="院系(部)管理团队";
	property name="TimeTables" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="TeacherTimeTable" hint="教师排课时间占用情况表";
	
	property name="Marks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="StudentMark" hint="学生学期成绩";
	property name="TempMarks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="StudentMarkTemp" hint="学生成绩临时记录";
	property name="MarkAduits" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="StudentMarkAduit" hint="成绩更正记录";

	property name="OpenTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="OpenTask" hint="单开班（主讲）";
	property name="OpenTasksSecondary" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_sec" cfc="OpenTask" hint="单开班（第二主讲）";
	property name="OpenTasksAssist" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_ace" cfc="OpenTask" hint="单开班（助课）";

	property name="CommonTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="CommonTask" hint="全校通选课（主讲）";
	property name="CommonTasksSecondary" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_sec" cfc="CommonTask" hint="全校通选课（第二主讲）";
	property name="CommonTasksAssist" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_ace" cfc="CommonTask" hint="全校通选课（助课）";

	property name="ProgramTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="ProgramTask" hint="计划课程（主讲）";
	property name="ProgramTasksSecondary" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_sec" cfc="ProgramTask" hint="计划课程（第二主讲）";
	property name="ProgramTasksAssist" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id_ace" cfc="ProgramTask" hint="计划课程（助课）";

	property name="ProgramSchemaModifySigns" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="sign_user_id" cfc="ProgramSchemaModify" hint="培养方案更改（申请）";
	property name="ProgramSchemaModifyAdmins" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="admin_user_id" cfc="ProgramSchemaModify" hint="培养方案更改（审批）";

	property name="TaskAdjustSigns" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="sign_user_id" cfc="TaskAdjust" hint="教学任务更改（申请）";
	property name="TaskAdjustAdmins" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="admin_user_id" cfc="TaskAdjust" hint="教学任务更改（审批）";

	property name="TaskMarkUnlockSigns" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="sign_user_id" cfc="TaskMarkUnlock" hint="成绩解锁（申请）";
	property name="TaskMarkUnlockAdmins" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="admin_user_id" cfc="TaskMarkUnlock" hint="成绩解锁（审批）";

	property name="StudentChangeAdmins" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="admin_user_id" cfc="StudentChange" hint="学籍异动（执行）";

	property name="TeacherWorkloads" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="TeacherWorkload" hint="教师工作量汇总表";

	property name="Questionnaires" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="tch_id" cfc="Questionnaire" hint="教师创建的调查问卷";

	property name="Institute" fieldtype="many-to-one" fkcolumn="institute_id" cfc="Institute"  hint="部门代码";
	property name="Type" fieldtype="many-to-one" fkcolumn="tch_type" cfc="TeacherType"  hint="教师类别代码";
	property name="TechnicalPosition" fieldtype="many-to-one" fkcolumn="tp_id" cfc="TechnicalPosition"  hint="职称代码";
	property name="TeacherEducational" fieldtype="many-to-one" fkcolumn="edu_id" cfc="TeacherEducational"  hint="学历代码";
	
	/**
	* @hint "生成外聘教师职工号"
	*/
	public string function getForginTeacherID() output=false {
		
		var nextID = "53000001";
		
		var checkArray = ORMExecuteQuery("select TeacherID 
											from Teacher 
											where TeacherID like :condition
											order by TeacherID desc", { condition="53______" }, { maxResults=1 });
		/* 
		主键生成规则 
			
		53开头 6位流水号
		*/

		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = "53" & numberFormat((right(checkArray[1], 6) + 1), "0_____");
		}
		
		return nextID;
	}
	
	
}

</cfscript>